package wjh.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import wjh.pojo.Admin;
import wjh.service.AdminInfoService;

@Controller
@RequestMapping("/adminInfo")
public class AdminInfo {
    @Autowired
    private AdminInfoService adminInfoService;

    @RequestMapping("/findAdminById")
    public String findAdminById(@RequestParam("id")String id,Model model){
        Admin admin = adminInfoService.findAdminById(Integer.parseInt(id));
        model.addAttribute("admin",admin);
        return "forward:/jsp/adminInfo.jsp";
    }
    @RequestMapping("/updateInfo")
    public String updateInfo(Admin admin,Model model){
        adminInfoService.updateInfo(admin);
        int id=admin.getId();
        model.addAttribute("id",id);
        model.addAttribute("admin",admin);
        return "adminIndex";//redirect:/user/findAll.do
    }
}
